<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>确认订单</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script type="text/javascript" src="/jquery.min.js"></script>
    <script type="text/javascript" src="/sb/Tips.min.js"></script>
</head>
<body>

<div class="" style="padding:15px;">

    <link rel="stylesheet" href="/goods/order.css"/>
    <div class="dd-wrapper" id="myElementId">
        <div class="dd-info">
            <p class="mb"><strong>订单编号：[[${orderVo.id}]]</strong></p>
        </div>
        <div class="dd-info">
            <p class="mb"><strong>订单状态：</strong>
                <b th:text="${T(com.b2c.entity.enums.third.EnumTmallOrderStatus).getName(orderVo.status)}"></b>
            </p>
        </div>
        <div class="dd-info">
            <p class="mb"><strong>收货人省市区：</strong>
                <b th:text="${orderVo.province}"></b>
                <b th:text="${orderVo.city}"></b>
                <b th:text="${orderVo.area}"></b>
            </p>
        </div>
    </div>
    <form class="layui-form layui-form-pane1">
        <input type="hidden" name="orderId" th:value="${orderVo.id}" />
        <div class="layui-form-item">
            <label class="layui-form-label">收货人</label>
            <div class="layui-input-block">
                <input type="text" name="receiver" autocomplete="off" lay-verify="required" lay-reqtext="收货人必填"
                       th:value="${orderVo.contactPerson}" placeholder="收货人" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">手机号</label>
            <div class="layui-input-block">
                <input type="text" name="mobile" lay-verify="required" autocomplete="off"
                       th:value="${orderVo.mobile}" placeholder="收货人手机号" maxlength="11" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">收货地址</label>
            <div class="layui-input-block">
                <input type="text" name="address" lay-verify="required" autocomplete="off" th:value="${orderVo.address}"
                       placeholder="收货地址" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">所属客户</label>
            <div class="layui-input-block">
                <select name="clientId" id="clientId" lay-search="">
                    <option value="">所属客户(支持搜索)</option>
                    <option th:each="item:${clientList}"
                            th:value="${item.id}" th:text="${item.developerName+'--'+item.userName}">等待付款
                    </option>
                </select>
            </div>

        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">卖家备注</label>
            <div class="layui-input-block">
                <textarea placeholder="卖家备注" name="sellerMemo" th:text="${orderVo.sellerMemo}" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" lay-filter="orderConfirm" class="layui-btn" lay-submit="" >订单确认</button>
                <i style="color: red" th:text="${error}"></i>
            </div>
        </div>
    </form>


    <!-- end dd-wrapper -->
    <script>
        //JavaScript代码区域
        var index = 0;
        try {
            index = parent.layer.getFrameIndex(window.name); //获取窗口索引
        }catch (e) {
        }
        var layer;
        var $;
        var form;
        layui.use(['laydate', 'jquery', 'form', 'layer'], function () {
            var laydate = layui.laydate;
            form = layui.form;
            layer = layui.layer;
            $ = layui.jquery;

            //监听提交
            form.on('submit(orderConfirm)', function(data){

                if(confirm("确定订单操作将会把该订单推送到仓库，是否要确认订单？")) {
                    $.ajax({
                        url: "/tao/order_confirm_post",
                        type: "POST",
                        dataType: "JSON",
                        contentType: 'application/json',
                        data: JSON.stringify(data.field),
                        success: function (res) {
                            if (res.code == 0) {
                                alert("确认成功！");
                                // location.href = '/tao_order/list?shopId=[[${orderVo.shopId}]]';
                            } else {
                                alert(res.msg);
                            }
                            parent.layer.close(index);
                            parent.location.reload();
                        }
                    })
                }
                // layer.alert(JSON.stringify(data.field), {
                //     title: '最终的提交信息'
                // })
                return false;
            });



        });
    </script>
</div>
</body>
<html>
